package com.linkgie.galaxyframework.binaryserialize;

import com.linkgie.galaxyframework.utils.TextEncoding;

public class FieldDataOptions implements DataOptions {

    private FieldSpecification fieldSpec;

    /**
     * @param fieldSpec
     */
    public FieldDataOptions(FieldSpecification fieldSpec) {
        this.fieldSpec = fieldSpec;
    }

    @Override
    public TextEncoding getTextEncoding() {
        if (fieldSpec.getPrimitiveType() == PrimitiveType.TEXT) {
            // 只有字段为文本类型({@link PrimitiveType#TEXT})时，文本编码选项才有效；
            return fieldSpec.getTextEncoding();
        }
        return null;
    }
}
